package com.example.servicemodule;

import android.os.RemoteException;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";

    private int mAge = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int n = remoteService.mListenerList.beginBroadcast();
                for (int i = 0; i < n; i++) {
                    OnInfoChangeAidlInterface onInfoChangeAidlInterface = remoteService.mListenerList.getBroadcastItem(i);
                    Student student = new Student();
                    student.setAge(mAge++);
                    try {
                        onInfoChangeAidlInterface.onNewInfo(student);
                    } catch (RemoteException e) {
                        e.printStackTrace();
                    }
                }
                remoteService.mListenerList.finishBroadcast();
            }
        });
        findViewById(R.id.bitmapState).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i(TAG, "onClick: remoteService.mBitmap" + remoteService.mBitmap);
                Log.i(TAG, "onClick: remoteService" + remoteService.mBitmap.isRecycled());
            }
        });
    }
}
